package org.example.server;

import lombok.Cleanup;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;


public class MServer
{
    public static void main( String[] args ) throws IOException, ClassNotFoundException {
        new MServer();

    }

    public MServer() throws IOException {
        @Cleanup ServerSocket serverSocket = new ServerSocket(8088);
        List<Socket> sockets = new ArrayList<>();
        Socket socket = null;
        while (true) {
            socket = serverSocket.accept();
            System.out.println(socket.getInetAddress().getHostAddress() + "客户端以连接");
            sockets.add(socket);
            ServerThread serverThread = new ServerThread(socket, sockets);
            new Thread(serverThread).start();
        }
    }
}
